home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / Mesa / lib / MesaAuto.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-02  |  2.3 KB  |  110 lines

  1.  
  2. /*
  3.  * AmigaMesaRTL graphics library
  4.  * Version:  1.1
  5.  * Copyright (C) 1998  Jarno van der Linden
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Library General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2 of the License, or (at your option) any later version.
  11.  *
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Library General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Library General Public
  18.  * License along with this library; if not, write to the Free
  19.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  */
  21.  
  22.  
  23. /*
  24.  * mesaauto.c
  25.  *
  26.  * Version 1.0  27 Jun 1998
  27.  * by Jarno van der Linden
  28.  * jarno@kcbbs.gen.nz
  29.  *
  30.  * Version 1.1  02 Aug 1998
  31.  * by Jarno van der Linden
  32.  * jarno@kcbbs.gen.nz
  33.  *
  34.  * - Added __stack to set enough stack
  35.  *
  36.  */
  37.  
  38.  
  39. #include <exec/types.h>
  40. #include <constructor.h>
  41.  
  42. #include <proto/dos.h>
  43. #include <proto/exec.h>
  44. #include <string.h>
  45.  
  46.  
  47. extern struct WBStartup *_WBenchMsg;
  48. extern char __stdiowin[];
  49.  
  50. struct Library *mesaBase;
  51. static void *libbase;
  52.  
  53. long __stack = 65536;
  54.  
  55. void mesaautoopenfail(char *lib, int ver)
  56. {
  57.    struct DOSBase *DOSBase;
  58.    long fh;
  59.    char buf[50];
  60.  
  61.    DOSBase = (struct DOSBase *)OpenLibrary("dos.library",0);
  62.    if (_WBenchMsg == NULL)
  63.       fh = Output();
  64.    else
  65.       fh = Open(__stdiowin, MODE_NEWFILE);
  66.  
  67.    if (fh)
  68.    {
  69.        RawDoFmt("Can't open version %ld of ",
  70.                 &ver, (void (*))"\x16\xC0\x4E\x75", buf);
  71.  
  72.        Write(fh, buf, strlen(buf));
  73.        Write(fh, lib, strlen(lib));
  74.        Write(fh, "\n", 1);
  75.  
  76.        if (_WBenchMsg)
  77.        {
  78.            Delay(200);
  79.            Close(fh);
  80.        }
  81.    }
  82.  
  83.  
  84.    CloseLibrary((struct Library *)DOSBase);
  85.    ((struct Process *)FindTask(NULL))->pr_Result2 =
  86.                       ERROR_INVALID_RESIDENT_LIBRARY;
  87.  
  88. }
  89.  
  90. CBMLIB_CONSTRUCTOR(openmesa)
  91. {
  92.    mesaBase = libbase =
  93.        (void *)OpenLibrary("mesa.library", 1);
  94.    if (mesaBase == NULL)
  95.    {
  96.      mesaautoopenfail("mesa.library", 1);
  97.      return 1;
  98.    }
  99.    return 0;
  100. }
  101.  
  102. CBMLIB_DESTRUCTOR(closemesa)
  103. {
  104.    if (libbase)
  105.    {
  106.       CloseLibrary((struct Library *)libbase);
  107.       libbase = mesaBase = NULL;
  108.    }
  109. }
  110.